<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cc{background-color:#ddd;}

    </style>
</head>
<body>
    <h1 id="hid">JavaScript实例-- 事件处理</h1>
    <button id="bid">点击我</button>

    <script>
        //使用js程序获取网页中的标签（元素节点）
        var hid = document.getElementById("hid");
        console.log(hid.innerHTML);
        //hid.innerHTML = "AAAAAAAAA";
        hid.style.color = "red";
        hid.classList.add("cc"); //为hid添加一个class属性值为cc

        //获取按钮
        var bn = document.querySelector("#bid");

        //为按钮绑定一个点击事件
        bn.onclick = function(){
            alert("ok");
        }
    </script>
</body>
</html>